import requests
import json
def translate(word):
    url = 'https://fanyi.baidu.com/sug'
    data = {
        'kw': word
    }
    response = requests.post(url, data=data)
    if response.status_code == 200:
        result = json.loads(response.text)
        if result.get('errno') == 0:
            for item in result.get('data'):
                print(f'{item.get("k")}：{item.get("v")}')
        else:
            print('翻译失败')
    else:
        print('请求失败')
if __name__ == '__main__':
    word = input('请输入需要翻译的单词：')
    translate(word)